package cn.ibobo.lease.admin.service.impl;

import cn.ibobo.lease.common.base.BaseMapper;
import cn.ibobo.lease.common.base.BaseServiceImpl;
import cn.ibobo.lease.admin.dao.DictMapper;
import cn.ibobo.lease.admin.service.DictService;
import cn.ibobo.lease.common.dto.DictDTO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import java.util.List;


/**
 * 字典表业务处理接口
 * @Author lililiang
 * @Date 2019-03-12 11:23:01
 */
@Service
public class DictServiceImpl extends BaseServiceImpl<DictDTO, String> implements DictService {

    private static final Log LOGGER = LogFactory.getLog(DictServiceImpl.class);

    @Autowired
    private DictMapper mapper;

    @Override
    protected BaseMapper<DictDTO, String> getMapper() {
        return mapper;
    }

    /**
     * 字典表列表
     * @Author lililiang
     * @Date 2019-03-12 11:23:01
     * @Param
     * @Return
     */
    @Override
    public List<DictDTO> list4Page(DictDTO entity, Integer pageNum, Integer... pageSize) {
        return super.list4Page(entity, pageNum, pageSize);
    }

    /**
     * 字典表列表（无分页）
     * @Author lililiang
     * @Date 2019-03-12 11:23:01
     * @Param
     * @Return
     */
    @Override
    public List<DictDTO> listByCondition(DictDTO entity) {
        return super.listByCondition(entity);
    }

    /**
     * 查询字典表详情信息
     * @Author lililiang
     * @Date 2019-03-12 11:23:01
     * @Param
     * @Return
     */
    @Override
    public DictDTO queryOneByPk(String id) {
        return super.queryOneByPk(id);
    }

    /**
     * 保存字典表信息
     * @Author lililiang
     * @Date 2019-03-12 11:23:01
     * @Param
     * @Return
     */
    @Override
    @Transactional
    public Integer save(DictDTO entity) {
        String id = entity.getId();
        if(id == null){
            return mapper.add(entity);
        }else{
            return mapper.edit(entity);
        }
    }

    /**
     * 删除字典表信息
     * @Author lililiang
     * @Date 2019-03-12 11:23:01
     * @Param
     * @Return
     */
    @Override
    @Transactional
    public Integer delete(String id) {
        return super.delete(id);
    }

    /**
     * @Description 根据主编码查询字典信息
     * @Author lililiang
     * @Date 2019/3/12 11:34
     * @Param [masterCode]
     * @Return cn.ibobo.lease.common.dto.DictDTO
     */
    @Override
    @Transactional
    public DictDTO queryOneByCode(String masterCode){
        return mapper.queryOneByCode(masterCode);
    }
}
